<!DOCTYPE html>
<script src=../../resources/testharness.js></script>
<script src=../../resources/testharnessreport.js></script>
<script>

// Run createStream() on a <video> source with protected content.

test(function() {
  var video = document.createElement('video');

  assert_equals(video.error, null);
  assert_equals(video.mediaKeys, null);
  video.onencrypted = this.step_func_done();

  navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access) {
    return access.createMediaKeys();
  }).then(function(mediaKeys) {
    return video.setMediaKeys(mediaKeys);
  }).then(function(result) {
    video.src = "../../media/content/test-encrypted.webm";
    assert_throws_dom("NotSupportedError",
                      function() { var stream = video.captureStream(); },
                      "Cannot create a captureStream() out of a protected <video>");
  });

}, 'check <video> captureStream() fails on an encrypted/protected media');

</script>
